home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / g.dxr / 00009_G ShortStock handlers.ls < prev    next >
Encoding:
Text File  |  1996-02-15  |  24.5 KB  |  658 lines

  1. global gHotRects, gObjects, sQTCharSprite, gHaveNavs, gWorld, gCPU
  2.  
  3. on setupG11C
  4.   set shortStockObj to getaProp(gObjects, #ShortTermStock)
  5.   set savedGameFlag to getaProp(shortStockObj, #savedGameFlag)
  6.   startTickerTrails()
  7.   if savedGameFlag = #false then
  8.     initFunctionAnimatorParams()
  9.     MakeDynamic(#ShortTimeIntervalParent, #State, #off)
  10.     MakeDynamic(#ShortTimeIntervalDisplay, #DisplayState, #false)
  11.     MakeDynamic(#ShortTimeGridDisplay, #DisplayState, #false)
  12.   else
  13.     if savedGameFlag = #true then
  14.       if getaProp(getaProp(gObjects, #ShortStocks), #currentChildDown) <> #none then
  15.         resetAnimatedGraphs()
  16.         Startthetimer(1, "setupGraphAnimations")
  17.         MakeDynamic(#ShortTimeIntervalParent, #State, #right)
  18.         MakeDynamic(#ShortTimeIntervalDisplay, #DisplayState, 5)
  19.         MakeDynamic(#ShortTimeGridDisplay, #DisplayState, 5)
  20.       end if
  21.       if getaProp(shortStockObj, #enteredPIN) = #valid then
  22.         resetGTextFields()
  23.         put string(getaProp(shortStockObj, #validPIN)) into field "G11PINDisplay.txt"
  24.         set currentAccountBalance to getaProp(getaProp(gObjects, #ShortTermStock), #AccountBalance)
  25.         put "$" && string(currentAccountBalance) into field "G11BalanceDisplay.txt"
  26.       end if
  27.     end if
  28.   end if
  29.   MakeDynamic(#ShortTermStock, #savedGameFlag, #true)
  30. end
  31.  
  32. on setupGraphAnimations
  33.   initAnimatedGraphs()
  34.   clearTimePricePlotPoints()
  35.   MakeDynamic(#ShortTermStock, #pricePricePreviousPoint, point(318, 314))
  36. end
  37.  
  38. on cleanupG11C
  39.   set updatedCredits to integer(getaProp(getaProp(gObjects, #ShortTermStock), #AccountBalance))
  40.   setaProp(gStates, #Credits, integer(updatedCredits))
  41.   set Debt to getaProp(gStates, #Debt)
  42.   if (updatedCredits - Debt) >= 15000 then
  43.     MakeDynamic(#ShortTermStock, #solved, #true)
  44.     setaProp(getaProp(gStates, #Conditions), #ShortStock, #true)
  45.   else
  46.     if getaProp(getaProp(gObjects, #PaMonitor), #HospPaid) = #false then
  47.       MakeDynamic(#ShortTermStock, #solved, #false)
  48.       setaProp(getaProp(gStates, #Conditions), #ShortStock, #false)
  49.     end if
  50.   end if
  51.   set xLineXOBJ to getaProp(getaProp(gObjects, #TrendPlotter), #LineXOBj)
  52.   if objectp(xLineXOBJ) then
  53.     xLineXOBJ(mdispose)
  54.   end if
  55.   MakeDynamic(#TrendPlotter, #LineXOBj, #NULL)
  56.   DelObjects([#ShortBalanceDisplay, #ShortPINDisplay])
  57.   set the trails of sprite getaProp(getaProp(gObjects, #TrendPlotter), #SpriteNum) to 0
  58.   setShortKeyBoardState(#on)
  59.   MakeDynamic(#ShortTermStock, #enteredPIN, #none)
  60.   MakeDynamic(#shortFeedback, #DisplayState, #INIT)
  61.   MakeDynamic(#ShortTermStock, #pinEntries, 0)
  62.   MakeDynamic(#ShortTermStock, #investAmount, 0)
  63.   MakeDynamic(#ShortTermStock, #chaosLastY, #NULL)
  64.   MakeDynamic(#ShortTermStock, #companySelected, #none)
  65.   resetStockSelectionKeys()
  66.   resetAmountSelectionKeys()
  67.   clearTimePricePlotPoints()
  68.   MakeDynamic(#ShortTermStock, #pricePricePreviousPoint, point(318, 314))
  69.   resetAnimatedGraphs()
  70.   MakeDynamic(#ShortTermStock, #savedGameFlag, #false)
  71. end
  72.  
  73. on resetStockSelectionKeys
  74.   set keyRef to getaProp(getaProp(gObjects, #ShortStocks), #currentChildDown)
  75.   if keyRef <> #none then
  76.     MakeDynamic(keyRef, #DisplayState, #UP)
  77.   end if
  78.   MakeDynamic(#ShortStocks, #currentChildDown, #none)
  79. end
  80.  
  81. on resetAmountSelectionKeys
  82.   set keyRef to getaProp(getaProp(gObjects, #ShortAmounts), #currentChildDown)
  83.   if keyRef <> #none then
  84.     MakeDynamic(keyRef, #DisplayState, #UP)
  85.   end if
  86.   MakeDynamic(#ShortAmounts, #currentChildDown, #none)
  87. end
  88.  
  89. on initFunctionAnimatorParams
  90.   set stockList to getaProp(getaProp(gObjects, #ShortStocks), #Children)
  91.   set chaosGenAList to getaProp(getaProp(gObjects, #ShortTermStock), #chaosGenA)
  92.   set chaosSeedYList to getaProp(getaProp(gObjects, #ShortTermStock), #chaosSeedY)
  93.   repeat with stockRef in stockList
  94.     set chaosGenA to (389.0 + float(random(11))) / 100
  95.     setaProp(chaosGenAList, stockRef, chaosGenA)
  96.     set chaosSeedY to float(random(1000)) / 1000
  97.     setaProp(chaosSeedYList, stockRef, chaosSeedY)
  98.   end repeat
  99.   MakeDynamic(#ShortTermStock, #chaosGenA, chaosGenAList)
  100.   MakeDynamic(#ShortTermStock, #chaosSeedY, chaosSeedYList)
  101. end
  102.  
  103. on getPINDisplayValue
  104.   set pinCastNum to the number of cast "G11PINDisplay.txt"
  105.   set pinDisplayValue to value(field "G11PINDisplay.txt")
  106.   return pinDisplayValue
  107. end
  108.  
  109. on setShortKeyBoardState inState
  110.   if symbolp(inState) then
  111.     MakeDynamic(#ShortKeyBoard, #State, inState)
  112.   else
  113.     put "bad parameter passed to setShortKeyBoardState"
  114.   end if
  115. end
  116.  
  117. on getShortKeyBoardState
  118.   set kBoardOList to getaProp(gObjects, #ShortKeyBoard)
  119.   set keyBoardState to getaProp(kBoardOList, #State)
  120.   return keyBoardState
  121. end
  122.  
  123. on DoStockKeyPad KeyNum
  124.   set currentPIN to getPINDisplayValue()
  125.   if integerp(KeyNum) then
  126.     if getShortKeyBoardState() = #on then
  127.       if field "G11PINDisplay.txt" = " " then
  128.         put string(KeyNum) into field "G11PINDisplay.txt"
  129.       else
  130.         put string(KeyNum) after field "G11PINDisplay.txt"
  131.       end if
  132.       if the number of chars in field "G11PINDisplay.txt" = 4 then
  133.         setShortKeyBoardState(#enterPIN)
  134.       end if
  135.     end if
  136.   else
  137.     if KeyNum = #return then
  138.       if currentPIN = getaProp(getaProp(gObjects, #ShortTermStock), #validPIN) then
  139.         doValidPIN()
  140.       else
  141.         put " " into field "G11PINDisplay.txt"
  142.         doInValidPIN()
  143.       end if
  144.     end if
  145.   end if
  146. end
  147.  
  148. on doValidPIN
  149.   MakeDynamic(#ShortTermStock, #enteredPIN, #valid)
  150.   playSound("G11ent.aif", #keyframeCast)
  151.   setShortKeyBoardState(#off)
  152.   displayShortFeedback("G11CFeedBackDummy")
  153.   MakeDynamic(#shortFeedback, #DisplayState, #NoFeedBack)
  154.   MakeDynamic(#ShortTermStock, #AccountBalance, getaProp(gStates, #Credits))
  155.   set currentAccountBalance to getaProp(getaProp(gObjects, #ShortTermStock), #AccountBalance)
  156.   put "$" && string(currentAccountBalance) into field "G11BalanceDisplay.txt"
  157.   if currentAccountBalance < 100 then
  158.     doAccountBalanceTooLow()
  159.   end if
  160. end
  161.  
  162. on doInValidPIN
  163.   MakeDynamic(#ShortTermStock, #enteredPIN, #none)
  164.   set currentPINEntries to getaProp(getaProp(gObjects, #ShortTermStock), #pinEntries)
  165.   set currentPINEntries to currentPINEntries + 1
  166.   MakeDynamic(#ShortTermStock, #pinEntries, currentPINEntries)
  167.   if currentPINEntries = 3 then
  168.     doGEndGame()
  169.   else
  170.     playSound("G20failc.aif", #keyframeCast)
  171.     Startthetimer(10, "displayInvalFeedback")
  172.     Startthetimer(180, "displayEnterPINFeedback")
  173.     setShortKeyBoardState(#on)
  174.   end if
  175. end
  176.  
  177. on displayInvalFeedback
  178.   set thisCastNum to the number of cast "G11INVAL.PCT"
  179.   displayShortFeedback(thisCastNum)
  180. end
  181.  
  182. on displayEnterPINFeedback
  183.   set thisCastNum to the number of cast "G11ENPIN.PCT"
  184.   displayShortFeedback(thisCastNum)
  185. end
  186.  
  187. on displayNoFeedback
  188.   set thisCastNum to the number of cast "G11CFeedBackDummy"
  189.   displayShortFeedback(thisCastNum)
  190. end
  191.  
  192. on displayShortFeedback inCastNameOrNum
  193.   if stringp(inCastNameOrNum) then
  194.     set feedbackCastNum to the number of cast inCastNameOrNum
  195.   else
  196.     if integerp(inCastNameOrNum) then
  197.       set feedbackCastNum to inCastNameOrNum
  198.     end if
  199.   end if
  200.   set shortFeedBackSprite to getaProp(getaProp(gObjects, #shortFeedback), #SpriteNum)
  201.   set the castNum of sprite shortFeedBackSprite to feedbackCastNum
  202.   updateStage()
  203. end
  204.  
  205. on doGEndGame
  206.   stopsound("Gstudy.aif")
  207.   genexitkf(#GDie)
  208. end
  209.  
  210. on doAccountBalanceTooLow
  211. end
  212.  
  213. on CountGTime inSeconds
  214.   set startTicks to the timer
  215.   repeat while the timer < (startTicks + (inSeconds * 60))
  216.     CursorandUpdate()
  217.     if the mouseDown then
  218.       exit
  219.     end if
  220.   end repeat
  221. end
  222.  
  223. on DoInvestAmountKeyPad inAmount
  224.   if getaProp(getaProp(gObjects, #shortFeedback), #DisplayState) = #SelectInvAmount then
  225.     displayNoFeedback()
  226.     MakeDynamic(#shortFeedback, #DisplayState, #NoFeedBack)
  227.   end if
  228.   MakeDynamic(#ShortTermStock, #investAmount, inAmount)
  229. end
  230.  
  231. on DoCompanySelectKeyPad inCompany
  232.   if getaProp(getaProp(gObjects, #ShortTermStock), #companySelected) = #none then
  233.     initAnimatedGraphs()
  234.   end if
  235.   erasePricePriceGraph()
  236.   resetPastTrendBar()
  237.   clearTimePricePlotPoints()
  238.   MakeDynamic(#ShortTermStock, #chaosLastY, #NULL)
  239.   if getaProp(getaProp(gObjects, #shortFeedback), #DisplayState) = #SelectStock then
  240.     displayNoFeedback()
  241.     MakeDynamic(#shortFeedback, #DisplayState, #NoFeedBack)
  242.   end if
  243.   MakeDynamic(#ShortTermStock, #companySelected, inCompany)
  244.   MakeDynamic(#ShortTimeIntervalParent, #State, #right)
  245. end
  246.  
  247. on DoShortBuy
  248.   if getaProp(getaProp(gObjects, #ShortTermStock), #enteredPIN) = #none then
  249.     playSound("G11buy.aif", #keyframeCast)
  250.     playSound("G11sell.aif", #keyframeCast)
  251.     flashPINDisplay()
  252.   else
  253.     if (getaProp(getaProp(gObjects, #ShortTermStock), #enteredPIN) = #valid) and (getaProp(getaProp(gObjects, #ShortTermStock), #companySelected) = #none) then
  254.       playSound("G11abort.aif", #keyframeCast)
  255.       displayShortFeedback("G11SELSK.PCT")
  256.       MakeDynamic(#shortFeedback, #DisplayState, #SelectStock)
  257.       updateStage()
  258.     else
  259.       if (getaProp(getaProp(gObjects, #ShortTermStock), #enteredPIN) = #valid) and (getaProp(getaProp(gObjects, #ShortTermStock), #investAmount) = 0) then
  260.         playSound("G11abort.aif", #keyframeCast)
  261.         displayShortFeedback("G11SELIN.PCT")
  262.         MakeDynamic(#shortFeedback, #DisplayState, #SelectInvAmount)
  263.         updateStage()
  264.       else
  265.         handleBuy()
  266.       end if
  267.     end if
  268.   end if
  269. end
  270.  
  271. on handleBuy
  272.   set AccountBalance to getaProp(getaProp(gObjects, #ShortTermStock), #AccountBalance)
  273.   set stocktoBuy to getaProp(getaProp(gObjects, #ShortTermStock), #companySelected)
  274.   set timeInterval to getaProp(getaProp(gObjects, #ShortTermStock), #timeInterval)
  275.   set investAmount to getaProp(getaProp(gObjects, #ShortTermStock), #investAmount)
  276.   set stockPrice to calcStockPrice()
  277.   if stockPrice > 0 then
  278.     set numSharesBought to integer(investAmount / stockPrice)
  279.   else
  280.     set numSharesBought to 0
  281.   end if
  282.   set moneySpent to numSharesBought * stockPrice
  283.   set newAccountBalance to AccountBalance - moneySpent
  284.   if newAccountBalance >= 100 then
  285.     MakeDynamic(#ShortTermStock, #AccountBalance, newAccountBalance)
  286.     setaProp(gStates, #Credits, integer(newAccountBalance))
  287.     updatePortfolioBuy(stocktoBuy, numSharesBought)
  288.     put "$" && string(newAccountBalance) into field "G11BalanceDisplay.txt"
  289.   else
  290.     displayShortFeedback("G11INFND.PCT")
  291.     Startthetimer(30, "jumpG11A")
  292.   end if
  293. end
  294.  
  295. on jumpG11A
  296.   Jumptokey(#G11a)
  297. end
  298.  
  299. on calcStockPrice
  300.   set company to getaProp(getaProp(gObjects, #ShortTermStock), #companySelected)
  301.   set dataList to getaProp(getaProp(gObjects, #ShortTermStock), #timePricePlotPoints)
  302.   set stockPrice to getAt(dataList, count(dataList))
  303.   return stockPrice
  304. end
  305.  
  306. on updatePortfolioBuy inStock, SharesBought
  307.   set portfolio to getaProp(getaProp(gObjects, #ShortTermStock), #shortPortfolio)
  308.   set sharesOwned to getaProp(getaProp(portfolio, inStock), #Shares)
  309.   set sharesOwned to sharesOwned + SharesBought
  310.   setaProp(getaProp(portfolio, inStock), #Shares, sharesOwned)
  311.   MakeDynamic(#ShortTermStock, #shortPortfolio, portfolio)
  312. end
  313.  
  314. on DoShortSell
  315.   if getaProp(getaProp(gObjects, #ShortTermStock), #enteredPIN) = #none then
  316.     playSound("G11buy.aif", #keyframeCast)
  317.     playSound("G11sell.aif", #keyframeCast)
  318.     flashPINDisplay()
  319.   else
  320.     if (getaProp(getaProp(gObjects, #ShortTermStock), #enteredPIN) = #valid) and (getaProp(getaProp(gObjects, #ShortTermStock), #companySelected) = #none) then
  321.       playSound("G11abort.aif", #keyframeCast)
  322.       displayShortFeedback("G11SELSK.PCT")
  323.       MakeDynamic(#shortFeedback, #DisplayState, #SelectStock)
  324.       updateStage()
  325.     else
  326.       if (getaProp(getaProp(gObjects, #ShortTermStock), #enteredPIN) = #valid) and (getaProp(getaProp(gObjects, #ShortTermStock), #investAmount) = 0) then
  327.         playSound("G11abort.aif", #keyframeCast)
  328.         displayShortFeedback("G11SELIN.PCT")
  329.         MakeDynamic(#shortFeedback, #DisplayState, #SelectInvAmount)
  330.         updateStage()
  331.       else
  332.         handleSell()
  333.       end if
  334.     end if
  335.   end if
  336. end
  337.  
  338. on handleSell
  339.   set AccountBalance to getaProp(getaProp(gObjects, #ShortTermStock), #AccountBalance)
  340.   set stocktoSell to getaProp(getaProp(gObjects, #ShortTermStock), #companySelected)
  341.   set timeInterval to getaProp(getaProp(gObjects, #ShortTermStock), #timeInterval)
  342.   set numSharesSold to updatePortfolioSell(stocktoSell)
  343.   set stockPrice to calcStockPrice()
  344.   set moneyEarned to numSharesSold * stockPrice
  345.   set newAccountBalance to AccountBalance + moneyEarned
  346.   MakeDynamic(#ShortTermStock, #AccountBalance, newAccountBalance)
  347.   setaProp(gStates, #Credits, integer(newAccountBalance))
  348.   put "$" && string(newAccountBalance) into field "G11BalanceDisplay.txt"
  349. end
  350.  
  351. on updatePortfolioSell inStock
  352.   set portfolio to getaProp(getaProp(gObjects, #ShortTermStock), #shortPortfolio)
  353.   set sharesOwned to getaProp(getaProp(portfolio, inStock), #Shares)
  354.   setaProp(getaProp(portfolio, inStock), #Shares, 0)
  355.   MakeDynamic(#ShortTermStock, #shortPortfolio, portfolio)
  356.   return sharesOwned
  357. end
  358.  
  359. on flashPINDisplay
  360.   global gTimerList
  361.   set cycleTicks to 30
  362.   repeat with i = 0 to 3
  363.     Startthetimer((i * cycleTicks) + 15, "displayNoFeedback")
  364.     Startthetimer((i * cycleTicks) + 30, "displayEnterPINFeedback")
  365.   end repeat
  366. end
  367.  
  368. on DoShortLogoff OBJref
  369.   set OBj to getaProp(gObjects, OBJref)
  370.   set overLayObj to getaProp(gObjects, #Shortreturn)
  371.   set overLaySpriteNum to getaProp(overLayObj, #SpriteNum)
  372.   if not voidp(getaProp(getaProp(OBj, #sound), #down)) then
  373.     playSound(getaProp(getaProp(OBj, #sound), #down), #keyframeCast)
  374.   end if
  375.   set the castNum of sprite overLaySpriteNum to getaProp(getaProp(overLayObj, #cast), #LogOffDown)
  376.   set the loc of sprite overLaySpriteNum to getaProp(overLayObj, #LogOffLoc)
  377.   updateStage()
  378.   repeat while the mouseDown
  379.     if inside(point(the mouseH, the mouseV), getAt(getaProp(OBj, #Hotrect), 1)) then
  380.       set the castNum of sprite overLaySpriteNum to getaProp(getaProp(overLayObj, #cast), #LogOffDown)
  381.       set the loc of sprite overLaySpriteNum to getaProp(overLayObj, #LogOffLoc)
  382.     else
  383.       set the castNum of sprite overLaySpriteNum to getaProp(getaProp(overLayObj, #cast), #UP)
  384.       set the loc of sprite overLaySpriteNum to getaProp(overLayObj, #loc)
  385.     end if
  386.     CursorandUpdate()
  387.   end repeat
  388.   set the castNum of sprite overLaySpriteNum to getaProp(getaProp(overLayObj, #cast), #UP)
  389.   set the loc of sprite overLaySpriteNum to getaProp(overLayObj, #loc)
  390.   updateStage()
  391.   Jumptokey(#G11a)
  392. end
  393.  
  394. on DoShortLeft
  395.   set displayStates to getaProp(getaProp(gObjects, #ShortTimeIntervalParent), #allStates)
  396.   set currentState to getaProp(getaProp(gObjects, #ShortTimeIntervalDisplay), #DisplayState)
  397.   set currentIndex to getPos(displayStates, currentState)
  398.   if currentState = 50 then
  399.     setaProp(getaProp(gObjects, #ShortTimeIntervalParent), #State, #both)
  400.   end if
  401.   if currentState = 10 then
  402.     setaProp(getaProp(gObjects, #ShortTimeIntervalParent), #State, #right)
  403.   end if
  404.   if currentState > 5 then
  405.     set newIndex to currentIndex - 1
  406.     set newState to getAt(displayStates, newIndex)
  407.     setTimeIntervalDisplays(newState)
  408.     setPastTrendBar()
  409.   end if
  410. end
  411.  
  412. on DoShortRight
  413.   set displayStates to getaProp(getaProp(gObjects, #ShortTimeIntervalParent), #allStates)
  414.   set currentState to getaProp(getaProp(gObjects, #ShortTimeIntervalDisplay), #DisplayState)
  415.   set currentIndex to getPos(displayStates, currentState)
  416.   if currentState = 5 then
  417.     setaProp(getaProp(gObjects, #ShortTimeIntervalParent), #State, #both)
  418.   end if
  419.   if currentState = 45 then
  420.     setaProp(getaProp(gObjects, #ShortTimeIntervalParent), #State, #left)
  421.   end if
  422.   if currentState < 50 then
  423.     set newIndex to currentIndex + 1
  424.     set newState to getAt(displayStates, newIndex)
  425.     setTimeIntervalDisplays(newState)
  426.     setPastTrendBar()
  427.   end if
  428. end
  429.  
  430. on setTimeIntervalDisplays inInterval
  431.   MakeDynamic(#ShortTermStock, #timeInterval, inInterval)
  432.   playSound(soundString(inInterval), #keyframeCast)
  433.   set OBJ1 to getaProp(gObjects, #ShortTimeIntervalDisplay)
  434.   set OBJ2 to getaProp(gObjects, #ShortTimeGridDisplay)
  435.   setaProp(OBJ1, #DisplayState, inInterval)
  436.   setaProp(OBJ2, #DisplayState, inInterval)
  437.   displayGObj(#ShortTimeIntervalDisplay)
  438.   displayGObj(#ShortTimeGridDisplay)
  439. end
  440.  
  441. on soundString timeInterval
  442.   if timeInterval = 5 then
  443.     return "G11t05.aif"
  444.   else
  445.     return "G11t" & string(timeInterval) & ".aif"
  446.   end if
  447. end
  448.  
  449. on erasePricePriceGraph
  450.   setaProp(getaProp(gObjects, #ShortTimeGridDisplay), #DisplayState, #erase)
  451.   displayGObj(#ShortTimeGridDisplay)
  452. end
  453.  
  454. on startTickerTrails
  455.   Startthetimer(30, "Trailit")
  456.   if gCPU = #mac then
  457.     set xLineXOBJ to MovieUtilities(mnew)
  458.   else
  459.     if gCPU = #mpc then
  460.       set xLineXOBJ to MovUtils(mnew)
  461.     end if
  462.   end if
  463.   setaProp(getaProp(gObjects, #TrendPlotter), #LineXOBj, xLineXOBJ)
  464. end
  465.  
  466. on Trailit
  467.   set the trails of sprite getaProp(getaProp(gObjects, #TrendPlotter), #SpriteNum) to 1
  468. end
  469.  
  470. on initAnimatedGraphs
  471.   set animChildrenRefList to getaProp(getaProp(gObjects, #ShortGraphs), #Children)
  472.   repeat with OBJref in animChildrenRefList
  473.     set newLoc to getaProp(getaProp(gObjects, OBJref), #loc2)
  474.     MakeDynamic(OBJref, #loc, newLoc)
  475.     set thisOBJAnim to getaProp(getaProp(gObjects, OBJref), #animator)
  476.     set the pCurrentLoc of thisOBJAnim to newLoc
  477.   end repeat
  478.   CursorandUpdate()
  479. end
  480.  
  481. on resetAnimatedGraphs
  482.   set animChildrenRefList to getaProp(getaProp(gObjects, #ShortGraphs), #Children)
  483.   repeat with OBJref in animChildrenRefList
  484.     set newLoc to getaProp(getaProp(gObjects, OBJref), #offloc)
  485.     MakeDynamic(OBJref, #loc, newLoc)
  486.   end repeat
  487. end
  488.  
  489. on updateTimePricePlotPoints inDataPoint
  490.   set dataList to getaProp(getaProp(gObjects, #ShortTermStock), #timePricePlotPoints)
  491.   set rawDataPoint to the locV of inDataPoint
  492.   set normalizedDataPoint to 79 - rawDataPoint
  493.   add(dataList, normalizedDataPoint)
  494.   if count(dataList) = 52 then
  495.     deleteAt(dataList, 1)
  496.   end if
  497.   setaProp(getaProp(gObjects, #ShortTermStock), #timePricePlotPoints, dataList)
  498. end
  499.  
  500. on clearTimePricePlotPoints
  501.   set dataList to getaProp(getaProp(gObjects, #ShortTermStock), #timePricePlotPoints)
  502.   set dataList to []
  503.   MakeDynamic(#ShortTermStock, #timePricePlotPoints, dataList)
  504. end
  505.  
  506. on setPastTrendBar
  507.   set PastOBJAnim to getaProp(getaProp(gObjects, #PastTrendBar), #animator)
  508.   set PresentOBJAnim to getaProp(getaProp(gObjects, #PresentTrendBar), #animator)
  509.   set pastSpriteNum to getaProp(getaProp(gObjects, #PastTrendBar), #SpriteNum)
  510.   set animationStepH to 2
  511.   set updateJumpH to 5
  512.   set barWidthOffset to the right of sprite getaProp(getaProp(gObjects, #PastTrendBar), #SpriteNum) - the left of sprite getaProp(getaProp(gObjects, #PastTrendBar), #SpriteNum)
  513.   set currentState to getaProp(getaProp(gObjects, #ShortTimeIntervalDisplay), #DisplayState)
  514.   set pixelOffset to currentState * getaProp(getaProp(gObjects, #ShortGraphs), #timeScale)
  515.   set currentPastLoc to the pCurrentLoc of PastOBJAnim
  516.   set currentPastLocH to the locH of currentPastLoc
  517.   set currentPastLocV to the locV of currentPastLoc
  518.   set currentPresentLoc to the pCurrentLoc of PresentOBJAnim
  519.   set currentPresentLocH to the locH of currentPresentLoc
  520.   if currentPresentLocH > currentPastLocH then
  521.     set currentOffsetH to currentPresentLocH - currentPastLocH
  522.   else
  523.     set currentOffsetH to currentPresentLocH - 34 + (526 - currentPastLocH)
  524.   end if
  525.   set updateCycles to 2
  526.   set newOffsetH to pixelOffset + barWidthOffset
  527.   if newOffsetH > currentOffsetH then
  528.     set updateFlag to #moveLeft
  529.     set targetPastLocH to currentPastLocH + (updateCycles * (animationStepH - updateJumpH))
  530.     repeat with i = 1 to updateCycles
  531.       set currentPastLoc to the pCurrentLoc of PastOBJAnim
  532.       set currentPastLocH to the locH of currentPastLoc
  533.       set newPastLocH to currentPastLocH - updateJumpH
  534.       if newPastLocH < 34 then
  535.         set newPastLocH to 526 - (34 - newPastLocH)
  536.       end if
  537.       set the loc of sprite pastSpriteNum to point(newPastLocH, currentPastLocV)
  538.       updateStage()
  539.     end repeat
  540.   else
  541.     set updateFlag to #moveRight
  542.     set targetPastLocH to currentPastLocH + (updateCycles * (animationStepH + updateJumpH))
  543.     repeat with i = 1 to updateCycles
  544.       set currentPastLoc to the pCurrentLoc of PastOBJAnim
  545.       set currentPastLocH to the locH of currentPastLoc
  546.       set newPastLocH to currentPastLocH + updateJumpH
  547.       if newPastLocH > 526 then
  548.         set newPastLocH to 34 + newPastLocH - 526
  549.       end if
  550.       set the loc of sprite pastSpriteNum to point(newPastLocH, currentPastLocV)
  551.       updateStage()
  552.     end repeat
  553.   end if
  554.   set timeInterval to getaProp(getaProp(gObjects, #ShortTermStock), #timeInterval)
  555. end
  556.  
  557. on resetPastTrendBar
  558.   set PastOBJAnim to getaProp(getaProp(gObjects, #PastTrendBar), #animator)
  559.   set PresentOBJAnim to getaProp(getaProp(gObjects, #PresentTrendBar), #animator)
  560.   set timeInterval to getaProp(getaProp(gObjects, #ShortTermStock), #timeInterval)
  561.   set updateJumpH to 2
  562.   set updateCycles to 2 * timeInterval / updateJumpH
  563.   set currentPastLoc to the pCurrentLoc of PastOBJAnim
  564.   set currentPastLocV to the locV of currentPastLoc
  565.   repeat with i = 1 to updateCycles
  566.     set currentPastLoc to the loc of sprite getaProp(getaProp(gObjects, #PastTrendBar), #SpriteNum)
  567.     set currentPastLocH to the locH of currentPastLoc
  568.     set newPastLocH to currentPastLocH + updateJumpH
  569.     if newPastLocH > 526 then
  570.       set newPastLocH to 34 + newPastLocH - 526
  571.     end if
  572.     set the loc of sprite getaProp(getaProp(gObjects, #PastTrendBar), #SpriteNum) to point(newPastLocH, currentPastLocV)
  573.     updateStage()
  574.   end repeat
  575.   repeat with i = 1 to 10 / updateJumpH
  576.     set currentPastLoc to the loc of sprite getaProp(getaProp(gObjects, #PastTrendBar), #SpriteNum)
  577.     set currentPastLocH to the locH of currentPastLoc
  578.     set newPastLocH to currentPastLocH - updateJumpH
  579.     if newPastLocH < 34 then
  580.       set newPastLocH to 526 - (34 - newPastLocH)
  581.     end if
  582.     set the loc of sprite getaProp(getaProp(gObjects, #PastTrendBar), #SpriteNum) to point(newPastLocH, currentPastLocV)
  583.     updateStage()
  584.   end repeat
  585.   setTimeIntervalDisplays(5)
  586. end
  587.  
  588. on displayGObj OBJref
  589.   set OBj to getaProp(gObjects, OBJref)
  590.   set the castNum of sprite getaProp(OBj, #SpriteNum) to getAt(getaProp(getaProp(OBj, #cast), getaProp(OBj, #DisplayState)), 1)
  591.   set the loc of sprite getaProp(OBj, #SpriteNum) to getaProp(OBj, #loc)
  592.   updateStage()
  593. end
  594.  
  595. on CalFromOffsets offset, RefName
  596.   set V to the locV of offset
  597.   set H to the locH of offset
  598.   set cur to getaProp(gObjects, RefName)
  599.   setaProp(cur, #loc, getaProp(cur, #loc) + offset)
  600.   setAt(getaProp(cur, #Hotrect), 1, getAt(getaProp(cur, #Hotrect), 1) + rect(H, V, H, V))
  601. end
  602.  
  603. on ToggleDNCOND OBJref
  604.   set OBj to getaProp(gObjects, OBJref)
  605.   if getaProp(getaProp(gObjects, getaProp(OBj, #Parent)), #State) = getaProp(OBj, #parentState) then
  606.     if not voidp(getaProp(getaProp(OBj, #sound), #down)) then
  607.       playSound(getaProp(getaProp(OBj, #sound), #down), #keyframeCast)
  608.     end if
  609.     set the castNum of sprite getaProp(OBj, #SpriteNum) to getaProp(getaProp(OBj, #cast), #down)
  610.     MakeDynamic(OBJref, #DisplayState, #down)
  611.     set lastButtonDown to getaProp(getaProp(gObjects, getaProp(OBj, #Parent)), #currentChildDown)
  612.     set lastObjDown to getaProp(gObjects, lastButtonDown)
  613.     MakeDynamic(getaProp(getaProp(gObjects, getaProp(OBj, #Parent)), #RefName), #currentChildDown, getaProp(OBj, #RefName))
  614.     if (lastButtonDown <> #none) and (lastButtonDown <> getaProp(OBj, #RefName)) then
  615.       set the castNum of sprite getaProp(lastObjDown, #SpriteNum) to getaProp(getaProp(lastObjDown, #cast), #UP)
  616.       MakeDynamic(lastButtonDown, #DisplayState, #UP)
  617.       updateStage()
  618.     end if
  619.     if not voidp(getaProp(getaProp(OBj, #Action), #UP)) then
  620.       do(getaProp(getaProp(OBj, #Action), #UP))
  621.     end if
  622.   end if
  623. end
  624.  
  625. on ButtonDNDUALCOND OBJref
  626.   set OBj to getaProp(gObjects, OBJref)
  627.   set onStates to getaProp(OBj, #parentState)
  628.   if (getaProp(getaProp(gObjects, getaProp(OBj, #Parent)), #State) = getAt(onStates, 1)) or (getaProp(getaProp(gObjects, getaProp(OBj, #Parent)), #State) = getAt(onStates, 2)) then
  629.     if not voidp(getaProp(getaProp(OBj, #sound), #down)) then
  630.       playSound(getaProp(getaProp(OBj, #sound), #down), #keyframeCast)
  631.     end if
  632.     set the castNum of sprite getaProp(OBj, #SpriteNum) to getaProp(getaProp(OBj, #cast), #down)
  633.     updateStage()
  634.     repeat while the mouseDown
  635.       if inside(point(the mouseH, the mouseV), getAt(getaProp(OBj, #Hotrect), 1)) then
  636.         set the castNum of sprite getaProp(OBj, #SpriteNum) to getaProp(getaProp(OBj, #cast), #down)
  637.       else
  638.         set the castNum of sprite getaProp(OBj, #SpriteNum) to getaProp(getaProp(OBj, #cast), #UP)
  639.       end if
  640.       CursorandUpdate()
  641.     end repeat
  642.     if not voidp(getaProp(getaProp(OBj, #sound), #UP)) then
  643.       playSound(getaProp(getaProp(OBj, #sound), #UP), #keyframeCast)
  644.     end if
  645.     do(getaProp(getaProp(OBj, #Action), #UP))
  646.     set the castNum of sprite getaProp(OBj, #SpriteNum) to getaProp(getaProp(OBj, #cast), #UP)
  647.     updateStage()
  648.   end if
  649. end
  650.  
  651. on jk1
  652.   Jumptokey(#G11a)
  653. end
  654.  
  655. on jk2
  656.   Jumptokey(#G11D)
  657. end
  658.